 1.创建MergeTree表，并测试CRUD操作
   
   1).创建表
CREATE TABLE mt_table
(
`date` Date,
`id` UInt8,
`name` String
)
ENGINE = MergeTree
PARTITION BY toYYYYMM(date)
ORDER BY id;
   2).插入数据
insert into mt_table values ('2019-05-01', 1, 'zhangsan');
insert into mt_table values ('2019-06-01', 2, 'lisi');
insert into mt_table values ('2019-05-03', 3, 'wangwu');
   3).更新操作
alter table mt_table update name='bailishouyue' where id =1;
   4).删除操作
alter table mt_table delete where id =2;
   5).查询操作
select * from mt_table;      


   
insert into mt_table values ('2019-05-01', 1, 'zhangsan');
insert into mt_table values ('2019-06-01', 2, 'lisi');
insert into mt_table values ('2019-05-03', 3, 'wangwu');   
 
 2.自己实现ClickHouse从kafka、MySql获取数据
   
   1).实现ClickHouse从mysql获取数据
CREATE TABLE mysql_table
(
`id` UInt32,
`name` String,
`age` UInt32
)
ENGINE = MySQL('192.168.71.102:3306', 'bigdata', 'student', 'root', '12345678')   
   2).实现ClickHouse从kafka获取数据
CREATE TABLE queue (
q_date String,
level String,
message String
) ENGINE = Kafka SETTINGS kafka_broker_list = 'linux121:9092',
kafka_topic_list = 'ch2',
kafka_group_name = 'group1',
kafka_format = 'CSV',
kafka_num_consumers = 1,
kafka_skip_broken_messages =10;

CREATE TABLE daily (
day Date,
level String,
message String
) ENGINE = MergeTree(day, (day, level), 8192);

CREATE MATERIALIZED VIEW consumer TO daily
as select q_date , level, message
from queue;
 